package com.sfdk.core
{
import com.sfdk.events.ConfigEvent;
import com.sfdk.io.GenericIO;

/**
	 * Class used to load the configuration data
	 * related to this preloader.
	 * 
	 * <p> The launcher xml contains three information :
	 * <ul>
	 * <li>The version</li>
	 * <li>The game name</li>
	 * <li>The game swf path</li>
	 * </ul>
	 * </p>
	 */
	 
	public class ConfigReader extends GenericIO
	{
		private const CONFIG_PATH : String = "config/";
		
		private var _configData : XML;
		
		public function ConfigReader(fileName : String = "game.xml")
		{
			super(CONFIG_PATH+fileName, GenericIO.XML_FILE);
		}
		
		override protected function init() : void
		{
			_configData = _fileInfo;
			dispatchEvent(new ConfigEvent(ConfigEvent.CONFIG_READ));
		}
		
		public function readConfig(data : String) : XML
		{
			var configContent : XMLList = _configData.elements(data);
			return (configContent[0] as XML);
		}
	}
}